import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class Livre extends Album{

	public static void getLivre( int visible ){
		
		String select = " SELECT a.titre FROM Livre l , Album a  where l.idlivre = a.idlivre and visible = " + visible;
		try {
			Statement stmt = Application.getStmt();
			stmt.executeUpdate("SET TRANSACTION READ ONLY");
			ResultSet res = stmt.executeQuery(select);
			
			while (res.next())
			{
				Album.addAlbum(res.getString(1));			
			}
			stmt.executeUpdate("COMMIT");
			res.close();
			
		} catch (SQLException e) {
			System.out.println("Erreur");
			e.printStackTrace();
		}
		
	}
	
	public static String afficher(Object object, int ordre ){
		
		String select = " SELECT i.chemin FROM Album a , Image i  , AlbumContient c, Livre l  where l.idLivre = a.idLivre and i.idimage = c.idimage and c.idAlbum = a.idAlbum and a.titre like '" + object + "' and c.numOrdre = " + ordre;
		
		String chemin = null ;
		try {
			Statement stmt = Application.getStmt();
			stmt.executeUpdate("SET TRANSACTION READ ONLY");
			ResultSet res = stmt.executeQuery(select);
			
			res.next();
			
		    chemin = res.getString(1);			
			
			stmt.executeUpdate("COMMIT");
			res.close();
			
			
		} catch (SQLException e) {
			System.out.println("Erreur");
			e.printStackTrace();
		}
		return chemin;
		
	}
	
	
	public void afficher(){
		
	}
	
	public static void gererLivre(){
		
	}
	
	

}
